package wyu.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.entity.CategoryBar;
import org.springframework.stereotype.Service;
import wyu.mapper.CategoryBarMapper;
@Service
public class CategoryBarServiceImpl extends ServiceImpl<CategoryBarMapper, CategoryBar> implements CategoryBarService {
    @Override
    public int getCategory(int barId) {
        CategoryBar categoryBar = query().eq("BAR_ID", barId).one();
        if (categoryBar==null){
            return 0;
        }
        int categoryId = categoryBar.getCategoryId();
        return categoryId;
    }

    @Override
    public boolean addRelevancy(int barId, int categoryId) {
        CategoryBar categoryBar = new CategoryBar();
        categoryBar.setBarId(barId);
        categoryBar.setCategoryId(categoryId);
        boolean save = save(categoryBar);
        return save;
    }
}
